import { isArray } from 'lodash/lang';
import storage from '@/utils/storage';
import { useUserStore } from "@/store";

const userSotre = useUserStore();
export function rolePermission(data) {
  const permissions = userSotre.permissionList || storage.get('PERMISSIONS');
  if (!permissions) {
    return false;
  }
  const isHave = permissions.includes(data);
  return isHave;
}

export function checkRole(data) {
  if (isArray(data)) {
    return data.some((item) => rolePermission(item));
  }
  return rolePermission(data);
}
